package com.up.upzl.biz.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import com.up.upzl.base.service.impl.BaseServiceImpl;
import com.up.upzl.biz.domain.SysAccountLoginLog;
import com.up.upzl.biz.repository.SysAccountLoginLogRepository;
import com.up.upzl.biz.service.SysAccountLoginLogService;

@Service
public class SysAccountLoginLogServiceImpl extends BaseServiceImpl<SysAccountLoginLog, Long> implements SysAccountLoginLogService {

	@Autowired
	private SysAccountLoginLogRepository sysAccountLoginLogRepository;
	
	@Override
	public Page<SysAccountLoginLog> findByCondition(Pageable page) {
		return sysAccountLoginLogRepository.findAll(new Specification<SysAccountLoginLog>() {

			@Override
			public Predicate toPredicate(Root<SysAccountLoginLog> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
				List<Predicate> predicates = new ArrayList<>();
					
				return cb.and(predicates.toArray(new Predicate[predicates.size()]));
			}
		}, page);
	}
}
